package com.guigu.service.security;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.Collection;

@Service
public class MyServiceImpl implements MyService {
    @Override
    public boolean hasPerssion(HttpServletRequest request, Authentication authentication) {
        Collection<? extends GrantedAuthority> obj = authentication.getAuthorities();
        return obj.contains(new SimpleGrantedAuthority(request.getRequestURI()));
    }
}
